/*
  The <multiboot.h> header file describes the data stuctures related to the multiboot standard.
 */

#ifndef _MULTIBOOT_H
#define _MULTIBOOT_H

#include <types.h>

/* SysMemMap values for field "type" */
// other values have to be treated as "reserved"

#define SMM_AVAILABLE    0x01   // available memory
#define SMM_RESERVED     0x02   // reserved,not available (e.g. system ROM, memory-mapped device)
#define SMM_ACPI_RECLAIM 0x03   // useable by OS after reading ACPI tables
#define SMM_ACPI_NVS     0x04   // OS is requested to save this memory between NVS sessions

#define CHECK_FLAG(flags,bit)   ((flags) & (1 << (bit)))

// align structures to 1 Byte boundary
//#pragma pack(push,1) // doesn't work with gcc-2.95
#pragma pack(1)  

/* The symbol table for a.out. */

struct aout_Symbol_Table_T
{
  dword_t tabsize;
  dword_t strsize;
  dword_t addr;
  dword_t reserved;
};

/* The section header table for ELF. */
struct elf_Section_Header_Table_T
{
  dword_t num;
  dword_t size;
  dword_t addr;
  dword_t shndx;
};

struct Multiboot_Info_T {
  dword_t flags;           // flags passed by bootloader
  dword_t mem_lower;       // memory below 1 MB (in Bytes)
  dword_t mem_upper;       // memory above 1 MB (in KBytes)
  dword_t boot_device;    
  dword_t cmdline;         // command line
  dword_t mods_count;      // boot modules count
  dword_t mods_addr;       // boot modules address
  union
  {
    struct aout_Symbol_Table_T aout_sym;
    struct elf_Section_Header_Table_T elf_sec;
  } syms;
  dword_t mmap_length;     // memory map length
  dword_t mmap_addr;       // memory map address
};

struct SysMemMap_T {
  dword_t size;            // size of structure
  dword_t base_addr_low;   // base address
  dword_t base_addr_high;  // base address
  dword_t bytes_low;       // length in Bytes
  dword_t bytes_high;      // length in Bytes
  dword_t type;            // type of area  
};

struct ModulesList_T {
  dword_t mod_start;       // module start address
  dword_t mod_end;         // module end address
  dword_t string;          // pointer to a string associated to this module
  dword_t reserved;        // set to zero (has to be ignored)  
};

// reset default structures alignment
//#pragma pack(pop) //doesn't work with gcc-2.95
#pragma pack(4)


// pointer to the structure passed in EBX by the bootloader at boot time
extern dword_t *GRUB_boot_header;
//extern dword_t mem_upper,mem_lower,mem_tot;

// Function prototypes
extern void parse_multi_boot_structure(void);

#endif /* _MULTIBOOT_H */
